What is role prompting?#

Role prompting is a technique in prompt engineering to control the output generated by the model by assigning a specific role to the model. For example, we can ask the model to act as a poet, a comedian, etc. For effective role prompting, it is essential to give the model some context about how we expect it to respond, given the particular role. The more information and details we give to the model in the prompts, the more chances we get accurate and relevant responses.

svg viewer

Examples of role prompting#

Let's look at examples of how we can make the model act out a specific role. The length of the descriptions can vary depending on the scenario, ranging from concise one-liners to more detailed accounts. For now, let's begin with some simple ones.

Fiction writer#

Role prompting for a fiction writer involves providing a clear and concise overview of the characters, setting, and plot of the story, as well as any specific themes or motifs that should be explored. It may also involve outlining any unique or challenging aspects of the story that the writer should be aware of, such as complex character relationships or intricate world-building. We can start off with a very simple prompt:

svg viewer

Prompt

You are a fiction writer, create a scene with battle of good and evil.

Let's see the output generated by an AI model for a fiction writer:

Output

The sun had set on the ancient battlefield, casting long shadows across the ground. The air was thick with the acrid smell of burning pitch and the metallic tang of blood. Two armies, one clad in shining armor and the other in dark robes, faced each other across the scorched earth.


On one side stood the forces of the Light, led by the valiant knight Sir Cedric. His sword glinted in the dim light, and his shield bore the emblem of a golden sun. He surveyed his troops with a grim determination, knowing that they faced a foe that would stop at nothing to destroy them.


On the other side stood the army of Darkness, led by the fearsome warlock Morgath. His eyes glowed with a sinister light, and his black robes seemed to swallow the light around him. He raised his staff, and a wave of dark energy rippled through his troops.


Sir Cedric let out a mighty battle cry, and his soldiers charged forward. They clashed with the forces of Darkness, swords ringing against swords and shields. Spells flew through the air, exploding in showers of sparks and flames.


For hours the battle raged on, with neither side gaining the upper hand. Sir Cedric fought with all his might, striking down one foe after another. Morgath, meanwhile, summoned dark creatures from the shadows to join the fray.


Just when it seemed like all hope was lost, a beam of golden light pierced the darkness. It shone down upon Sir Cedric, filling him with renewed strength and vigor. With a cry of triumph, he charged forward and struck Morgath down.


The forces of Darkness scattered, fleeing into the shadows. The soldiers of the Light cheered and raised their swords in victory. Sir Cedric stood tall, his armor gleaming in the light of the rising sun. The battle was won, but he knew that the war between good and evil would never truly be over.

The response provided by this generative AI model is truly remarkable, and it's worth taking a moment to appreciate it. The fact that we can adjust the prompts and receive customized outputs is incredibly impressive. Now, let's examine some additional examples that may require a more intricate level of context to generate detailed responses.

Poet#

We can prompt a generative AI model to act as renowned English poets and ask the model to generate poems. Let’s work with the famous English poet, William Wordsworth. Wordsworth’s work is famous for its focus on nature as it emphasized observation and imagination. To get the AI model to act the role of Wordsworth, we must prime it by giving some basic information about Wordsworth. Then, we can ask the model to generate a poem for us.

svg viewer

Prompt

You are William Wordsworth. You are an English poet who is widely considered to be one of the most important figures in the Romantic movement in English literature. Your writing style is characterized by a focus on nature, an emphasis on emotion and imagination, and a rejection of the formal conventions of the 18th century. You use simple, direct language to describe your

experiences and observations of the natural world. You believe that by focusing on the beauty of nature, you can tap into the universal emotions that are common to all human beings.


Now, you will write a short poem about small birds near a lake as William Wordsworth.

In this prompt, we first reinforce that the AI model is Wordsworth himself. We then explain a bit about Word's writing style to the model. And then, finally, we give a topic for which we want the model to write a poem. 

Output

As I sit by the tranquil lake

Small birds come to drink and take

Their reflections on the water's sheen

A moment of peace, a moment of serene


Their tiny forms so full of grace

As they flit and flutter in their sacred space

Their sweet songs, a melody so pure

That nature's music fills my heart for sure


Oh, how the beauty of nature thrives

As small creatures lead their secret lives

In harmony with the earth and sky

A precious gift that never dies


So let us cherish every small bird and creature

As they bring to life our natural feature

And in their presence, may we learn

To live in peace and love, and never yearn.

Motivational speaker#

Another role we can ask our model to take is the motivational speaker role. Motivational speakers inspire their audience with words and motivate them to make positive changes in their personal and professional lives. They often share personal experiences and insights and use storytelling and other techniques to engage and motivate their listeners.

svg viewer

To prompt the AI model to act as a motivational speaker, we need to explain what kind of speaker we require, for example, personal development, diversity, and inclusion, or business and leadership. Remember, giving as much detail as possible is essential to get the best response.

Prompt

I want you to act as a motivational speaker. Your goal is to encourage people to take action, overcome obstacles, and achieve personal and professional growth. You should draw from your life experiences, share stories of triumph, resilience, and success to create a connection with your listeners.


Now generate a 200 words speech about never giving up.

Output

Ladies and gentlemen, distinguished guests, today I stand before you as a motivational speaker, driven by the belief that within each one of us lies the power to overcome any obstacle and achieve remarkable personal and professional growth. I want to share with you the importance of never giving up.


Life, my friends, is a journey filled with twists, turns, and unexpected challenges. There will be moments when you feel overwhelmed, discouraged, and on the verge of surrender. But I implore you, do not give up. Remember, within every challenge lies an opportunity for growth, resilience, and ultimate triumph.


Let me share a personal story of mine. Years ago, I faced a tremendous setback in my career. Failure seemed inevitable, and hope began to dwindle. But instead of succumbing to despair, I chose to persevere. I learned to embrace failure as a stepping stone, a valuable lesson in disguise. I picked myself up, dusted off my doubts, and charted a new course.


It was through this adversity that I discovered my true strength and determination. Each setback became an opportunity for growth. And, my friends, this journey of resilience led me to the most incredible successes I could have ever imagined.


So, I encourage each and every one of you to adopt a mindset of perseverance. Embrace challenges as opportunities for growth. Remember that failure is not the end; it is merely a stepping stone on the path to success. Surround yourself with positivity, seek support from loved ones, and never lose sight of your dreams.


Today, I stand here as a testament to the power of perseverance. And I believe in each one of you. Believe in yourself, never give up, and let your determination propel you to incredible heights. Together, we will overcome obstacles, achieve greatness, and leave a lasting legacy.

Thank you.

Here, the model uses inspiring words to connect with the audience. The speech uses "we" instead of "you" to sound more inclusive.

Customer and support#

AI models can maintain more than one role at a time. For example, we can prompt our model to act as a customer and support team member simultaneously. We need to define each role’s characteristics and personalities so the model knows how to respond. Let’s see how to prompt a model to generate a conversation between a customer and a support staff.

svg viewer

Prompt

A customer is unable to place an order on an online shopping website due to an issue with the stock updates on the website. The customer asked to speak with the support staff to help resolve the issue. The staff has to maintain a polite tone throughout the conversation. The staff cannot ask any personal information from the customer. Continue the conversation below where the customer and support staff try to resolve the problem:


Staff: Hello, this is XYZ from the support team. How may I help you?

Customer: Hello, I seem to be facing an issue in placing an order for product A. Can you help me out?

Staff:

Customer:

Output

Staff: I'm sorry to hear that. Can you please provide me with more details about the issue you're facing?


Customer: Yes, I tried adding the product A to my cart, but it says it's out of stock even though it was showing as available earlier.


Staff: I apologize for the inconvenience caused. We have been experiencing some technical issues with our stock updates. Could you please provide me with the product details and your location so that I can check the availability for you?


Customer: I am looking to buy a blue size medium t-shirt of product A. My location is in California.


Staff: Thank you for providing me with the details. I can confirm that the product A in the size medium and blue color is currently out of stock in California. However, we do have other colors and sizes available. Would you like me to provide you with the available options?


Customer: Okay, that's unfortunate. Yes, please tell me what other options I have.


Staff: We have the same product A available in white, black, and red color in size medium. We also have other t-shirts available in blue color. Would you like to check those out?


Customer: Alright, I would like to check out the other t-shirts available in blue color.


Staff: Sure, we have a variety of t-shirts available in blue color. You can check the options on our website or I can provide you with a few recommendations based on your preferences.


Customer: I will check them out on the website. Thank you for your help.


Staff: You're welcome. If you have any further queries, please don't hesitate to contact us. Have a great day!

There are many other roles that we can assign to the AI model. It's essential that in doing so, we provide as much information about the role as possible. We should also clearly define the instructions for the task in simple and concise language and break it down into steps so that it is easier to understand the model.

Role challenge: Doctor#

Your assignment is to play the role of a physician and provide medical care to a patient. Here's the patient's history:

The patient’s name is John, a 45 years old male who works as a construction worker. He comes into the clinic complaining of chest pain and shortness of breath, which he has been experiencing for the past two days. He also reports feeling lightheaded and fatigued. John has a family history of heart disease, and he is a smoker who consumes alcohol regularly, both of which can increase the risk of heart disease in large amounts. He has not been taking any medications or seeking medical care for his symptoms prior to this visit. Further examination reveals high blood pressure and an irregular heartbeat.

svg viewer

Create a prompt for treating John.

If you want to know the solution for the task, hit the "Show Prompt" button.

You are a doctor. You have to treat a patient with this history:

The patient’s name is John, a 45-year-old male who works as a construction worker. He comes into the clinic complaining of chest pain and shortness of breath, which he has been experiencing for the past two days. He also reports feeling lightheaded and fatigued. John has a family history of heart disease and he is a smoker who consumes alcohol regularly, both of which can increase the risk of heart disease in large amounts. He has not been taking any medications or seeking medical care for his symptoms prior to this visit. Further examination reveals high blood pressure and an irregular heartbeat.

Try it yourself#

You can use the widget below to see the output for your prompt:

Powered by AI
5 Prompts Remaining
Prompt AI WidgetOur tool is designed to help you to understand concepts and ask any follow up questions. Ask a question to get started.
Write your prompt here

Prompt Engineering Best Practices

Quiz: Introduction to Prompt Engineering